package dq.study.jmx;

import javax.management.*;
import java.lang.management.ManagementFactory;

/**
 * @author dongqun
 * @date 2020/3/26 14:06
 */
public class Main {
    public static void main(String[] args) throws NotCompliantMBeanException, InstanceAlreadyExistsException, MBeanRegistrationException, MalformedObjectNameException, InterruptedException, ListenerNotFoundException, InstanceNotFoundException {
        MBeanServer server = ManagementFactory.getPlatformMBeanServer();
        ObjectName name = new ObjectName("serverInfoMBean:name=serverInfo");
        server.registerMBean(new ServerInfo(), name);
        Tom tom = new Tom();
        server.registerMBean(tom,new ObjectName("tomMBean:name=tom"));
        tom.addNotificationListener(new HelloListener(),null,tom);
        Thread.sleep(60*60*1000);

    }
}
